1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : planspiel/classes/class.color_indicator.inc.php
5 : - Modulgruppe: Planspiel
6 : - Beschreibung: Setzt die Farben des BarCharting Diagramms
7 : - Version: 1.0
8 : - Autor(en): Marcel Knapp <marcel.knapp@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : +--------------------------------------------------------------------------*/
23 : /**
24 : * Setzt die Farben des BarCharting Diagramms
25 : * @package eStudy.Planspiel
26 : * @version 1.0
27 : * @author Marcel Knapp <marcel.knapp@mni.fh-giessen.de>
28 : */
29 1 : class ColorIndicator {
30 :
31 : // colors properties
32 : public $border_color;
33 : public $chartname_bgcolor;
34 : public $chartname_font_color;
35 : public $bar_bgcolor_dark;
36 : public $bar_bgcolor_light;
37 : public $font_color;
38 : public $break_color;
39 : public $arrow_color;
40 : public $budget_color; // Farbe für den Bugdet-Indikator im Planspiel
41 : public $tooltip; // Tooltip für die Farben
42 : // member variables
43 : private $indicator_calor;
44 : private $actual_state_value;
45 : private $target_state_value;
46 : private $is_budget = false;
47 :
48 : function ColorIndicator($actual_state_value, $target_state_value) {
49 0 : $this->actual_state_value = $actual_state_value;
50 0 : $this->target_state_value = $target_state_value;
51 : // Set the indicator color
52 0 : $this->calculate_indicator();
53 0 : $this->set_colors();
54 :
55 0 : }
56 :
57 : public function set_indicator_color($color){
58 0 : $this->indicator_calor = $color;
59 0 : $this->set_colors();
60 0 : }
61 :
62 : public function is_budget (){
63 0 : $this->is_budget = true;
64 0 : $this->set_colors();
65 0 : }
66 :
67 : private function calculate_indicator () {
68 : /*
69 : * GEWICHTUNG:
70 : * <= 0% -> green
71 : * <= 10% -> yellow
72 : * <= 20% -> orange
73 : * <= 30% -> red
74 : * > 30 % -> darkred
75 : */
76 0 : if ($this->actual_state_value == 0 || $this->target_state_value == 0) {
77 0 : $this->indicator_calor = "grey";
78 0 : } else {
79 0 : if ($this->actual_state_value >= $this->target_state_value + 10) {
80 0 : $this->indicator_calor = "green";
81 0 : } else if ($this->actual_state_value >= $this->target_state_value) {
82 0 : $this->indicator_calor = "blue";
83 0 : } else {
84 : //$value = 100 - ($this->actual_state_value * 100 / $this->target_state_value);
85 0 : $value = $this->target_state_value - $this->actual_state_value;
86 0 : if ($value <= 10) {
87 0 : $this->indicator_calor = "yellow";
88 0 : } else if ($value <= 20) {
89 0 : $this->indicator_calor = "orange";
90 0 : } else if ($value <= 30) {
91 0 : $this->indicator_calor = "red";
92 0 : } else {
93 0 : $this->indicator_calor = "darkred";
94 : }
95 : }
96 : }
97 0 : }
98 :
99 : private function set_colors () {
100 0 : if ($this->indicator_calor == "green") {
101 0 : $this->arrow_color = "#1B7E24";
102 0 : $this->border_color = "#2C9C2A";
103 0 : $this->chartname_bgcolor = "#2C9C2A";
104 0 : $this->chartname_font_color = "#FFFFFF";
105 0 : $this->bar_bgcolor_dark = "#78E382";
106 0 : $this->bar_bgcolor_light = "#DDFFDA";
107 0 : $this->font_color = "#1B7E24";
108 0 : $this->break_color = "#2C9C2A";
109 0 : $this->budget_color = "#2BCD27";
110 0 : if (!$this->is_budget) {
111 0 : $this->tooltip = "Sehr gut in der Zeit (+10%)";
112 0 : }
113 : else {
114 0 : $this->tooltip = "Budget eingehalten, aber nicht ausgeschöpft";
115 : }
116 0 : } else if ($this->indicator_calor == "blue") {
117 0 : $this->arrow_color = "#2A629C";
118 0 : $this->border_color = "#2A629C";
119 0 : $this->chartname_bgcolor = "#2A629C";
120 0 : $this->chartname_font_color = "#FFFFFF";
121 0 : $this->bar_bgcolor_dark = "#7DB0E4";
122 0 : $this->bar_bgcolor_light = "#C9DDF2";
123 0 : $this->font_color = "#204F7F";
124 0 : $this->break_color = "#2A629C";
125 0 : $this->budget_color = "#50AEDF";
126 0 : if (!$this->is_budget) {
127 0 : $this->tooltip = "Gut in der Zeit";
128 0 : }
129 : else {
130 0 : $this->tooltip = "Budget eingehalten";
131 : }
132 0 : } else if ($this->indicator_calor == "yellow") {
133 0 : $this->arrow_color = "#818513";
134 0 : $this->border_color = "#B9B70D";
135 0 : $this->chartname_bgcolor = "#B9B70D";
136 0 : $this->chartname_font_color = "#FFFFFF";
137 0 : $this->bar_bgcolor_dark = "#FEFC69";
138 0 : $this->bar_bgcolor_light = "#FFFECA";
139 0 : $this->font_color = "#818513";
140 0 : $this->break_color = "#B9B70D";
141 0 : $this->budget_color = "#FCF365";
142 0 : if (!$this->is_budget) {
143 0 : $this->tooltip = "Liegt bis zu 10% zurück";
144 0 : }
145 : else {
146 0 : $this->tooltip = "Budget leicht Überschritten";
147 : }
148 0 : } else if ($this->indicator_calor == "orange") {
149 0 : $this->arrow_color = "#9C7B14";
150 0 : $this->border_color = "#B98F0D";
151 0 : $this->chartname_bgcolor = "#B98F0D";
152 0 : $this->chartname_font_color = "#FFFFFF";
153 0 : $this->bar_bgcolor_dark = "#F3CA5B";
154 0 : $this->bar_bgcolor_light = "#FCF1C9";
155 0 : $this->font_color = "#9C7B14";
156 0 : $this->break_color = "#B98F0D";
157 0 : $this->budget_color = "#FF9914";
158 0 : if (!$this->is_budget) {
159 0 : $this->tooltip = "Liegt bis zu 20% zurück";
160 0 : }
161 : else {
162 0 : $this->tooltip = "Budget Überschritten";
163 : }
164 0 : } else if ($this->indicator_calor == "red") {
165 0 : $this->arrow_color = "#B43D19";
166 0 : $this->border_color = "#BD401A";
167 0 : $this->chartname_bgcolor = "#DE491C";
168 0 : $this->chartname_font_color = "#FFFFFF";
169 0 : $this->bar_bgcolor_dark = "#FF8B67";
170 0 : $this->bar_bgcolor_light = "#FFC7B6";
171 0 : $this->font_color = "#AA3917";
172 0 : $this->break_color = "#BD401A";
173 0 : $this->budget_color = "#F43C1E";
174 0 : if (!$this->is_budget) {
175 0 : $this->tooltip = "Liegt bis zu 30% zurück";
176 0 : }
177 : else {
178 0 : $this->tooltip = "Budget stark Überschritten";
179 : }
180 0 : } else if ($this->indicator_calor == "darkred") {
181 0 : $this->arrow_color = "#8F2C0E";
182 0 : $this->border_color = "#8F2C0E";
183 0 : $this->chartname_bgcolor = "#8F2C0E";
184 0 : $this->chartname_font_color = "#FFFFFF";
185 0 : $this->bar_bgcolor_dark = "#CE1111";
186 0 : $this->bar_bgcolor_light = "#FFC3C3";
187 0 : $this->font_color = "#7D290F";
188 0 : $this->break_color = "#79250B";
189 0 : $this->budget_color = "#B82A13";
190 0 : if (!$this->is_budget) {
191 0 : $this->tooltip = "Liegt mehr als 30% zurück";
192 0 : }
193 : else {
194 0 : $this->tooltip = "Budget sehr stark Überschritten";
195 : }
196 0 : } else if ($this->indicator_calor == "grey") {
197 0 : $this->arrow_color = "#818181";
198 0 : $this->border_color = "#818181";
199 0 : $this->chartname_bgcolor = "#818181";
200 0 : $this->chartname_font_color = "#FFFFFF";
201 0 : $this->bar_bgcolor_dark = "#BBBABA";
202 0 : $this->bar_bgcolor_light = "#E1DDDC";
203 0 : $this->font_color = "#535353";
204 0 : $this->break_color = "#818181";
205 0 : $this->budget_color = "#BCBCBC";
206 0 : if (!$this->is_budget) {
207 0 : $this->tooltip = "Inaktiv (noch nicht begonnen)";
208 0 : }
209 : else {
210 0 : $this->tooltip = "Noch kein Budget verbraucht";
211 : }
212 0 : }
213 0 : }
214 : }
215 : ?>
|